package one.stand.service;

import com.alibaba.fastjson.JSON;
import one.stand.OneLoginServiceApplicationTests;
import one.stand.code.RedisCode;
import one.stand.entity.TokenEntity;
import one.stand.request.SendSmsCodeRequest;
import one.stand.util.RedisUtil;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.TestConfiguration;

import java.util.concurrent.TimeUnit;

/**
 * @author: QIK
 * @CreateDate: 2019/4/16 18:33
 */
@TestConfiguration
public class Login extends OneLoginServiceApplicationTests {
    @Autowired
    HomeService homeService;

    @Autowired
    protected RedisUtil redisUtil;

    @Test
    public void loginPc() {
        System.err.println(JSON.toJSON(homeService.getPcLoginImg("")));
    }

    @Test
    public void pcLoginCallBack() {
        System.err.println(JSON.toJSON(homeService.pcLoginCallBack("081aQxz82Xc5xJ0RvSy82T0Kz82aQxzT", "one-stand")));
    }
    @Test
    public void sendSms(){
        SendSmsCodeRequest request=new SendSmsCodeRequest();
        request.setPhone("1592844fsdafafdsfdsds4521");
        request.setType(1);
        homeService.sendSms(request);
    }

    @Test
    public void getLoginInfo() {
        String token = "zBcBgmx3dP_121";
        TokenEntity tokenModel = new TokenEntity();
        tokenModel.setRoleId(324332324);
        //redisUtil.set(RedisCode.getUserLoginToken(token), tokenModel, 7000, TimeUnit.SECONDS);
        System.err.println(JSON.toJSONString(redisUtil.get(RedisCode.getUserLoginToken(token))));

        System.err.println(JSON.toJSONString(homeService.getLoginInfo(token)));
    }
}
